import { Tag } from "antd"
import { ColumnGroupType, ColumnType } from "antd/es/table"

const useBmhColumn = (newFormat: (arg: string) => string): Record<string, ColumnGroupType<any> | ColumnType<any>> => ({
	bmhCreatedAt: {
		dataIndex: "createdAt",
		title: newFormat("member.virtual_currency_account_information.binding_time"),
		render: (value: any, record: any) => <p>{record.createdAt}</p>,
		width: 150,
		align: "center",
		key: "createdAt"
	},

	bmhName: {
		dataIndex: "bmhName",
		title: newFormat("member.bmh.bmh_account"),
		render: (value: any, record: any) => <p>{record.bmhName}</p>,
		width: 150,
		align: "center",
		key: "bmhName"
	},

	bmhAccountStatus: {
		dataIndex: "accountStatus",
		title: newFormat("member.bmh.bmh_account_status"),
		width: 150,
		align: "center",
		key: "accountStatus",
		render: (_text: any, record: any) =>
			(() => {
				let context: string = ""
				let color = "green"
				if (record.bindStatus === 0) {
					context = newFormat("common.account_status_bind")
					color = "red"
				} else if (record.paymentLockStatus) {
					context = newFormat("common.account_status_normal")
					color = "green"
				}
				return (
					<span>
						<Tag color={color}>{context}</Tag>
					</span>
				)
			})()
	},

	bmhWindControlName: {
		dataIndex: "windControlName",
		title: newFormat("member.bmh.bmh_account_windControl_level"),
		render: (value: any, record: any) => <p>{record.windControlName}</p>,
		width: 150,
		align: "center",
		key: "windControlName"
	}
})

export default useBmhColumn
